﻿using System.Runtime.Serialization;

namespace Ping.Core
{
	/// <summary>
	/// One data-set in a GeoResult that contains the information associated with one IP-Address.
	/// </summary>
	[DataContract]
	public sealed class GeoDataSet
	{
		[DataMember]
		public string AreaCode { get; set; }

		[DataMember]
		public string City { get; set; }

		[DataMember]
		public string ContinentCode { get; set; }

		[DataMember]
		public string ContinentName { get; set; }

		[DataMember]
		public string CountryCode { get; set; }

		[DataMember]
		public string CountryName { get; set; }

		[DataMember]
		public string DmaCode { get; set; }

		[DataMember]
		public GeoPosition Position { get; set; }

		[DataMember]
		public string Region { get; set; }

		[DataMember]
		public string RegionCode { get; set; }

		[DataMember]
		public string RegionName { get; set; }
	}

	/// <summary>
	/// Contains all data resulting from a geo-location job.
	/// </summary>
	/// <remarks>
	/// All fields beside the Position are optional and are filled with null if they could not be located.
	/// </remarks>
	[DataContract]
	public sealed class GeoResult
		: Result
	{
		/// <summary>
		/// The collection of data-sets, one per IP-Address.
		/// </summary>
		[DataMember] public GeoDataSet[] DataSets;

		public int Count
		{
			get { return DataSets != null ? DataSets.Length : 0; }
		}
	}
}